package com.hmall.api.client;

import com.hmall.api.config.DefaultFeignConfig;
import com.hmall.api.dto.ItemDTO;
import com.hmall.api.dto.OrderDetailDTO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


/**
 * 当前类是Feign接口，主要作用是用来远程调用商品微服务
 */
//通过@FeignClient注解指定需要访问的注册中心的服务
@FeignClient(value = "item-service",
        configuration = DefaultFeignConfig.class)
public interface ItemClient {

    //这里就和controller一样

    //根据id集合查询商品信息
    @GetMapping("items")
    List<ItemDTO> queryItemByIds(@RequestParam("ids") List<Long> ids);

    @PutMapping("items/stock/deduct")
    public void deductStock(@RequestBody List<OrderDetailDTO> items);
}
